<template>
  <div v-loading="true" element-loading-text="统一认证中..." class="custom-text"></div>
</template>

<script setup lang="ts">
import { onBeforeMount } from 'vue'
import { util, token } from '@/utils'
import { authApi } from '@/api/modules/auth/auth'
import { ElMessage } from 'element-plus'

const verifyCode = (code: string) => {
  authApi.ssoVerifyCode(code, util.getSSORedirectUri()).then(resp => {
    if (resp.success) {
      token.set(resp.data)
      location.href = import.meta.env.VITE_BASE_URL
    } else {
      ElMessage.error(resp.message)
    }
  })
}

onBeforeMount(() => {
  const params = util.getSearch()
  if (params && params.code) {
    verifyCode(params.code)
  }
})
</script>

<style lang="scss" scoped>
.custom-text {
  margin-top: 10%;
  :deep(.el-loading-text) {
    font-size: x-large;
  }
}
</style>
